package com.sctvcloud.qingchuan.ui.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.ruihang.generalibrary.ui.adapter.BaseHolderAbsAdapter;
import com.ruihang.generalibrary.ui.util.OnItemInternalClick;
import com.sctvcloud.qingchuan.R;
import com.sctvcloud.qingchuan.beans.PoliticsReplyDotBean;
import com.sctvcloud.qingchuan.ui.adapter.holder.BaseAbsHolder;
import com.sctvcloud.qingchuan.ui.adapter.holder.PoliticsUserReplyHolder;

import java.util.List;

/**
 * 用户对融媒号回复的追问以及融媒号对追问的回复
 */
public class PoliticsDetailReplyListAdapter extends BaseHolderAbsAdapter<PoliticsReplyDotBean, BaseAbsHolder<PoliticsReplyDotBean>> {
    private OnItemInternalClick onItemInternalClick;
    private PoliticsUserReplyHolder.OnReplyClickListener replyClickListener;

    public PoliticsDetailReplyListAdapter(Context context, List<PoliticsReplyDotBean> list, PoliticsUserReplyHolder.OnReplyClickListener replyClickListener) {
        super(context, list);
        this.replyClickListener = replyClickListener;
    }


    @Override
    public BaseAbsHolder<PoliticsReplyDotBean> onCreateViewHolder(ViewGroup parent, int viewType) {
        BaseAbsHolder bah;
        LayoutInflater inflater = LayoutInflater.from(context);
        View v = inflater.inflate(R.layout.item_politics_repley_list, parent, false);
        bah = new PoliticsUserReplyHolder(context, v, replyClickListener);
        return bah;
    }

    @Override
    public int getItemViewType(int position) {
        return data.get(position).getDataViewType();
    }

    @Override
    public void onItemInternalClick(View itemView, View view, int position) {
        if (onItemInternalClick != null) {
            onItemInternalClick.onItemInternalClick(itemView, view, position);
        }
    }

    @Override
    public PoliticsDetailReplyListAdapter setItemInternalClick(OnItemInternalClick itemInternalClick) {
        this.onItemInternalClick = itemInternalClick;
        return this;
    }

}
